package com.jilefojing.dao.impl;

import java.util.Arrays;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import tk.mybatis.mapper.entity.Example;

import com.jilefojing.beans.pojos.EBook;
import com.jilefojing.dao.IEBookDao;
import com.jilefojing.dao.base.impl.BaseDao;
import com.jilefojing.dao.mapper.IEBookMapper;

/**
 * 
 * @author 作者 jgshun
 * @date 创建时间 2016年09月30日 20时11分24秒
 */
@Repository
public class EBookDao extends BaseDao<EBook> implements IEBookDao {
	@Autowired
	private IEBookMapper eBookMapper;

	@Override
	public List<EBook> getListByIds(List<Long> ids) {
		Example example = new Example(EBook.class);
		example.createCriteria().andIn(EBook.FIELD_ID, ids);
		return super.getListByExample(example);
	}

	@Override
	public List<EBook> getListByParentId(long parentId) {
		return this.getListByParentIds(Arrays.asList(new Long[] { parentId }));
	}

	@Override
	public List<EBook> getListByParentIds(List<Long> parentIds) {
		Example example = new Example(EBook.class);
		example.createCriteria().andIn(EBook.FIELD_PARENTID, parentIds);
		example.setOrderByClause(EBook.ORDER_CHILD_SORT_ASC);
		return super.getListByExample(example);
	}
}
